/*
 * Copyright 2008 Zoundry LLC, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package org.zoundry.gaedt.core.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import test.org.zoundry.gaedt.core.ZGaeCoreTestCase;

/**
 * Tests the utf8Util util class.
 */
public class ZGaeUTF8UtilTest extends ZGaeCoreTestCase
{
    /**
     * Unit test.
     *
     * @throws Exception
     */
    public void testGetInputStream() throws Exception
    {
        String content = "The quick brown fox jumped over the lazy dog.";
        InputStream inputStream = ZGaeUTF8Util.getInputStream(content);
        assertNotNull("UTF8 Input Stream should not be null.", inputStream);
        try
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String expected = content;
            String actual = reader.readLine().trim();
            assertEquals(expected, actual);
        }
        finally
        {
            ZGaeCloser.close(inputStream);
        }
    }
}
